package com.cjm.one.model.order.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

import com.cjm.one.model.base.BaseEntity;
import com.cjm.one.model.order.enums.PayTypeEnum;
import com.cjm.one.model.order.enums.OrderStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 订单
 * @TableName order_info
 */
@TableName(value ="order_info")
@Data
public class
OrderInfo extends BaseEntity {
    /**
     * id
     */
//    @TableId(type = IdType.AUTO)
//    private Long id;

    /**
     * 会员_id
     */
    @Schema(description = "会员_id")
    @TableField(value = "custom_id")
    private Long customId;

    /**
     * 昵称
     */
    @Schema(description = "昵称")
    @TableField(value = "nick_name")
    private String nickName;

    /**
     * 订单号
     */
    @Schema(description = "订单号")
    @TableField(value = "order_no")
    private String orderNo;



    /**
     * 订单总额
     */
    @Schema(description = "订单总额")
    @TableField(value = "total_amount")
    private BigDecimal totalAmount;

    /**
     * 优惠券
     */
    @Schema(description = "优惠券")
    @TableField(value = "coupon_amount")
    private BigDecimal couponAmount;

    /**
     * 原价金额
     */
    @Schema(description = "原价金额")
    @TableField(value = "original_total_amount")
    private BigDecimal originalTotalAmount;

    /**
     * 运费
     */
    @Schema(description = "运费")
    @TableField(value = "feight_fee")
    private BigDecimal feightFee;

    /**
     * 支付方式【1->微信 2->支付宝】
     */
    @Schema(description = "支付方式【1->微信 2->支付宝】")
    @TableField(value = "pay_type")
    private PayTypeEnum payType;

    /**
     * 订单状态【0->待付款；1->待发货；2->已发货；3->待用户收货，已完成；-1->已取消】
     */
    @Schema(description = "订单状态【0->待付款；1->待发货；2->已发货；3->待用户收货，已完成；-1->已取消】")
    @TableField(value = "order_status")
    private OrderStatusEnum orderStatus;

    @Schema(description = "退款时间")
    @TableField(value = "refund_time")
    private LocalDateTime refundTime;

    @Schema(description = "退款金额")
    @TableField(value = "refund_amount")
    private BigDecimal refundAmount;
    /**
     * 收货人姓名
     */
    @Schema(description = "收货人姓名")
    @TableField(value = "receiver_name")
    private String receiverName;

    /**
     * 拒绝退款原因
     */
    @Schema(description = "拒绝退款原因")
    @TableField(value = "no_refund_reason")
    private String noRefundReason;
    /**
     * 退款原因

     **/
    @Schema(description = "退款原因")
    @TableField(value = "reason_for_refund")
    private String reasonForRefund;

    /**
     * 收货人电话
     */
    @Schema(description = "收货人电话")
    @TableField(value = "receiver_phone")
    private String receiverPhone;

    /**
     * 收货人地址标签
     */
    @Schema(description = "收货人地址标签")
    @TableField(value = "receiver_tag_name")
    private String receiverTagName;

    /**
     * 省份/直辖市
     */
    @Schema(description = "省份/直辖市")
    @TableField(value = "receiver_province")
    private String receiverProvince;

    /**
     * 城市
     */
    @Schema(description = "城市")
    @TableField(value = "receiver_city")
    private String receiverCity;

    @Schema(description = "商品数量")
    @TableField(value = "goods_num")
    private Integer goodsNum;


    /**
     * 区
     */
    @Schema(description = "区")
    @TableField(value = "receiver_district")
    private String receiverDistrict;

    /**
     * 详细地址
     */
    @Schema(description = "详细地址")
    @TableField(value = "receiver_address")
    private String receiverAddress;

    /**
     * 支付时间
     */
    @Schema(description = "支付时间")
    @TableField(value = "payment_time")
    private LocalDateTime paymentTime;

    /**
     * 发货时间
     */
    @Schema(description = "发货时间")
    @TableField(value = "delivery_time")
    private LocalDateTime deliveryTime;

    @Schema(description = "订单完成时间")
    @TableField(value = "complete_time")
    private LocalDateTime completeTime;

    @Schema(description = "拒绝退款时间")
    @TableField(value = "no_refund_time")
    private LocalDateTime noRefundTime;

    /**
     * 确认收货时间
     */
    @Schema(description = "确认收货时间")
    @TableField(value = "receive_time")
    private LocalDateTime receiveTime;

    @Schema(description = "开始退款时间")
    @TableField(value = "start_refund_time")
    private LocalDateTime startRefundTime;

    /**
     * 订单备注
     */
    @Schema(description = "订单备注")
    @TableField(value = "remark")
    private String remark;

    /**
     * 取消订单时间
     */
    @Schema(description = "取消订单时间")
    @TableField(value = "cancel_time")
    private LocalDateTime cancelTime;

    /**
     * 取消订单原因
     */
    @Schema(description = "取消订单原因")
    @TableField(value = "cancel_reason")
    private String cancelReason;

    @Schema(description = "第三方支付流水号")
    @TableField(value = "trade_no")
    private String tradeNo;

    @Schema(description = "退款描述")
    @TableField(value = "refund_description")
    private String refundDescription;

    @Schema(description = "请求ID")
    @TableField(value = "request_id")
    private String requestId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof OrderInfo orderInfo)) return false;
        if (!super.equals(o)) return false;
        return Objects.equals(getCustomId(), orderInfo.getCustomId()) && Objects.equals(getNickName(), orderInfo.getNickName()) && Objects.equals(getOrderNo(), orderInfo.getOrderNo())  && Objects.equals(getTotalAmount(), orderInfo.getTotalAmount()) && Objects.equals(getCouponAmount(), orderInfo.getCouponAmount()) && Objects.equals(getOriginalTotalAmount(), orderInfo.getOriginalTotalAmount()) && Objects.equals(getFeightFee(), orderInfo.getFeightFee()) && getPayType() == orderInfo.getPayType() && getOrderStatus() == orderInfo.getOrderStatus() && Objects.equals(getRefundTime(), orderInfo.getRefundTime()) && Objects.equals(getRefundAmount(), orderInfo.getRefundAmount()) && Objects.equals(getReceiverName(), orderInfo.getReceiverName()) && Objects.equals(getReceiverPhone(), orderInfo.getReceiverPhone()) && Objects.equals(getReceiverTagName(), orderInfo.getReceiverTagName()) && Objects.equals(getReceiverProvince(), orderInfo.getReceiverProvince()) && Objects.equals(getReceiverCity(), orderInfo.getReceiverCity()) && Objects.equals(getGoodsNum(), orderInfo.getGoodsNum()) && Objects.equals(getReceiverDistrict(), orderInfo.getReceiverDistrict()) && Objects.equals(getReceiverAddress(), orderInfo.getReceiverAddress()) && Objects.equals(getPaymentTime(), orderInfo.getPaymentTime()) && Objects.equals(getDeliveryTime(), orderInfo.getDeliveryTime()) && Objects.equals(getReceiveTime(), orderInfo.getReceiveTime()) && Objects.equals(getRemark(), orderInfo.getRemark()) && Objects.equals(getCancelTime(), orderInfo.getCancelTime()) && Objects.equals(getCancelReason(), orderInfo.getCancelReason()) && Objects.equals(getTradeNo(), orderInfo.getTradeNo());
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), getCustomId(), getNickName(), getOrderNo(), getTotalAmount(), getCouponAmount(), getOriginalTotalAmount(), getFeightFee(), getPayType(), getOrderStatus(), getRefundTime(), getRefundAmount(), getReceiverName(), getReceiverPhone(), getReceiverTagName(), getReceiverProvince(), getReceiverCity(), getGoodsNum(), getReceiverDistrict(), getReceiverAddress(), getPaymentTime(), getDeliveryTime(), getReceiveTime(), getRemark(), getCancelTime(), getCancelReason(), getTradeNo());
    }

    @Override
    public String toString() {
        return "OrderInfo{" +
                "customId=" + customId +
                ", nickName='" + nickName + '\'' +
                ", orderNo='" + orderNo + '\'' +
                ", totalAmount=" + totalAmount +
                ", couponAmount=" + couponAmount +
                ", originalTotalAmount=" + originalTotalAmount +
                ", feightFee=" + feightFee +
                ", payType=" + payType +
                ", orderStatus=" + orderStatus +
                ", refundTime=" + refundTime +
                ", refundAmount=" + refundAmount +
                ", receiverName='" + receiverName + '\'' +
                ", receiverPhone='" + receiverPhone + '\'' +
                ", receiverTagName='" + receiverTagName + '\'' +
                ", receiverProvince='" + receiverProvince + '\'' +
                ", receiverCity='" + receiverCity + '\'' +
                ", goodsNum=" + goodsNum +
                ", receiverDistrict='" + receiverDistrict + '\'' +
                ", receiverAddress='" + receiverAddress + '\'' +
                ", paymentTime=" + paymentTime +
                ", deliveryTime=" + deliveryTime +
                ", receiveTime=" + receiveTime +
                ", remark='" + remark + '\'' +
                ", cancelTime=" + cancelTime +
                ", cancelReason='" + cancelReason + '\'' +
                ", tradeNo='" + tradeNo + '\'' +
                '}';
    }

}